/**
 * 设定该全局对象全局只读不可改
 * @param {*} object 需要全局只读的对象
 * @returns {object}
 */
function getReadOnlyObject(object) {
    Object.keys(object).forEach(key => {
        Object.defineProperty(object, key, {
            writable: false
        })
    })
    return object
}

// 获取当前运行环境 develop release trial
const env = __wxConfig.envVersion
console.log(env)
// 定义普通请求地址
const baseUrls = getReadOnlyObject({
    // develop: 'http://192.168.1.190:10000',
    // develop: 'http://192.168.1.201:8889',
    // develop: 'http://192.168.1.250:8889', // 郑哥 
    // develop: 'http://192.168.110.230:8889',
    // develop: 'http://192.168.110.207:8889', // 杜哥
    // develop: 'http://192.168.110.230:8889',
    // develop: 'http://192.168.110.134:8889', // 龙哥的神仙端口
    // develop: 'http://192.168.110.188:8889', // 经纬
    // develop: 'http://192.168.110.89:8889', // 栋哥
    // develop: 'http://192.168.1.108:8889',
    // develop: 'https://pay.51zidan.com',
    // develop: 'http://192.168.1.222:8889', // 代哥
    // develop: 'http://192.168.1.161:8889',
    // develop: 'http://106.52.229.46:8889',
    // develop: 'http://192.168.1.185:8889',
    // develop: 'http://192.168.110.188:8889', // 经纬
    // develop: 'http://192.168.110.151:8889',
    develop: 'https://test.51zidan.com/testpay',
    release: 'https://pay.51zidan.com',
    trial: 'https://test.51zidan.com/testpay',
    // trial: 'http://192.168.1.222:8889' 
})

// 定义websocket地址
const wsUrls = getReadOnlyObject({
    develop: 'wss://ws.51zidan.com',
    // develop: 'wss://192.168.1.222:8889',
    // develop: 'ws://192.168.1.222:8811',
    // develop: 'wss://test.51zidan.com/testws',
    release: 'wss://ws.51zidan.com',
    trial: 'wss://test.51zidan.com/testws',
})

// 抛出全局参数
export default {
    env,
    baseUrl: baseUrls[env],
    qrCodeUrl: baseUrls[env] === 'https://pay.51zidan.com' ? 'https://blue.51zidan.com': baseUrls[env],
    // zpUrl: baseUrls[env].indexOf('https') !== -1 ? '/newjob' : '',
    zpUrl: '',
    wsUrl: wsUrls[env],
    appId: __wxConfig.accountInfo.appId,
    session_key: ''
}